
from time import sleep
from py_code.driver.DriverManager import DriverManager
from py_code.driver.Ultrasonic import Ultrasonic
from py_code.driver.CarDriver import CarDriver
import logging

# logging.basicConfig函数对日志的输出格式及方式做相关配置
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s')

while True:
    print(DriverManager().getDriver(Ultrasonic()).distance())
    car = DriverManager().getDriver(CarDriver())
    car.go(50)
    sleep(1)
    car.stop()
    sleep(1)
    car.run(80, -50)
    sleep(1)
    car.stop()
    sleep(1)
